<template>
  <div>
    <el-dialog :title="formValue.id ? '编辑' : '新增'" :visible="visible" width="60%" @close="onClose" :close-on-click-modal="false">
      <el-form :model="formValue" :rules="formRules" ref="formRef" :class="$style.root">
        <el-row>
          <el-col :span="12">
            <el-form-item label="顶级渠道" :label-width="formLabelWidth" prop="topChannelCode">
              <el-select
                v-model="formValue.topChannelCode"
                placeholder="请选择"
                style="width: 80%"
                clearable
                :disabled="!!formValue.id"
                @change="topChannelChange"
              >
                <el-option v-for="item in topChannelList" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司编码" :label-width="formLabelWidth" prop="companyCode">
              <el-input :disabled="!!formValue.id" v-model="formValue.companyCode" placeholder="公司编码" style="width: 80%" clearable />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="商品编码" :label-width="formLabelWidth" prop="goodsCode">
              <el-input
                v-model="formValue.goodsCode"
                :disabled="!!formValue.id"
                placeholder="商品编码"
                style="width: 80%"
                clearable
                @blur="goodsCodeBlur()"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="商品名称" :label-width="formLabelWidth" prop="goodsName">
              <el-input v-model="formValue.goodsName" placeholder="商品名称" style="width: 80%" clearable :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商品类型" :label-width="formLabelWidth" prop="goodsType">
              <el-select clearable v-model="formValue.goodsType" placeholder="请选择" style="width: 80%" filterable>
                <el-option v-for="item in goodsTypeList" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="最低毛利" :label-width="formLabelWidth" prop="minGross">
              <el-input v-model="formValue.minGross" placeholder="最低毛利" style="width: 80%" clearable />%
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原价限购数量" :label-width="formLabelWidth" prop="limitNum">
              <el-input v-model="formValue.limitNum" placeholder="原价限购数量" style="width: 80%" clearable />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="原价限购频率" :label-width="formLabelWidth" prop="limitFrequency">
              <el-input v-model="formValue.limitFrequency" placeholder="原价限购频率" style="width: 80%" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="特价限购数量" :label-width="formLabelWidth" prop="activityPriceLimit">
              <el-input v-model="formValue.activityPriceLimit" placeholder="特价限购数量" style="width: 80%" clearable />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否自动化调价" :label-width="formLabelWidth" prop="autoPrice">
              <el-select clearable v-model="formValue.autoPrice" placeholder="请选择" style="width: 80%" filterable>
                <el-option label="是" value="Y" />
                <el-option label="否" value="N" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" style="text-align: center">
        <el-button @click="onSubmit('formRef')" type="primary" :loading="onSubmitIng">确定</el-button>
        <el-button @click="onClose">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<style lang="scss" module>
@import './index.module.scss';
</style>

<script>
import Index from './index';
export default Index;
</script>
